<!DOCTYPE html>
<html lang="en">
	<?php
	if(!isset($_SESSION)){
	session_start();
	}
	?>
	<head>
		<meta charset="utf-8" />

		<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
		Remove this if you use the .htaccess -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

		<title>IDeascover - Inbox</title>

		<meta name="viewport" content="width=device-width; initial-scale=1.0" />

		<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
		<link rel="shortcut icon" href="/favicon.ico" />
		<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
		<script type="text/javascript">
			function checkUsername() {
			}
		</script>
		<SCRIPT language="JavaScript">
		<!--hide

		if (<?php !isset($_SESSION['username']) ?>) {
		 window.location="<?php echo base_url("user/login")?>";
		 }

		//-->
		</SCRIPT>
		<!-- Link Template -->
		<link href="<?php echo base_url("Templates/site.css")?>" rel="stylesheet" type="text/css" />
		<link href="<?php echo base_url("Templates/styles.css")?>" rel="stylesheet" type="text/css" />
		<link href="<?php echo base_url("Templates/jquery.confirm/jquery.confirm.css")?>" rel="stylesheet" type="text/css" />
		<link href='http://fonts.googleapis.com/css?family=Cuprum&subset=latin' rel='stylesheet' type='text/css'>
		<script type="text/javascript" src="<?php echo base_url("Templates/js/jquery.js")?>"></script>
		<script type="text/javascript" src="<?php echo base_url("Templates/js/jquery.form.js")?>"></script>
		<script type="text/javascript" src="<?php echo base_url("Templates/js/init.js")?>"></script>
		<script type="text/javascript" src="<?php echo base_url("Templates/jquery.confirm/jquery.confirm.js")?>"></script>
		<!-- -->
	</head>

	<body>
<!-- Body Template -->
		<div id="fb-root"></div>
		<script>(function(d, s, id) {
		  var js, fjs = d.getElementsByTagName(s)[0];
		  if (d.getElementById(id)) return;
		  js = d.createElement(s); js.id = id;
		  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
		  fjs.parentNode.insertBefore(js, fjs);
		}(document, 'script', 'facebook-jssdk'));</script>
		<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
		<div id="container">

			<div id="header">
			<div id="logo"><a href="<?php echo base_url("mainpage/")?>"><img src="<?php echo base_url("images/logo.png")?>" style="position:absolute; z-index:1" /></a><a href="<?php echo base_url("ideas/addNewIdea")?>"><img id="newidea" src="<?php echo base_url("images/newidea.png")?>" style="position:absolute; margin-left:210px; z-index:0" /></a></div>
			<div id="login">
			<?php
				if (isset($_SESSION['userObject']) )
				{
				?>
				<div id="loginuser">
				<?php $current = $_SESSION['userObject']?>
				<a href="<?php echo base_url("user/profile/$current->user_username "); ?>">
				<img id="userimg" height="60px" src="<?php echo base_url("images/upload/user/thumbs/$current->user_profilepict")?>">
				<span style="text-decoration:none;color:#fff;">
				<?php
				echo  $current->user_username;
				?>
				</span>
				</a>
				<ul id="profilemenu" cellspacing="3px" style="color:#fff;font-color:#fff;">
					<a href="<?php echo base_url("message")?>" style="text-decoration:none;">
					<li class="option"><span style="text-decoration:none;color:#fff;">Messages</span></li></a>
					<a href="<?php echo base_url("ideas/userIdeas/$current->user_username")?>" style="text-decoration:none;">
					<li class="option"><span style="text-decoration:none;color:#fff;">My Ideas</span></li></a>
					<a href="<?php echo base_url("feed/manage/")?>" style="text-decoration:none;">
					<li class="option"><span style="text-decoration:none;color:#fff;">My Follow</span></li></a>
					<a href="<?php echo base_url("user/manage_profile/$current->user_username")?>" style="text-decoration:none;">
					<li class="option"><span style="text-decoration:none;color:#fff;">My Settings</span></li></a>

					<a href="<?php echo base_url("user/logout")?>" style="text-decoration:none;">
					<li class="option"><span style="text-decoration:none;color:#fff;">Logout</span></li>
					</a>
				</ul>
				</div>
				<?php
				}
			?>
			</div>
			</div>

			<div id="bodyer">
			<div id="sidebar">
<!-- Start of search function -->
				<table border="0" cellpadding="1" align="center" style="margin:0px auto;">
				  <tr>
					<?php echo form_open('search/doSearch')?>
					<td><input type="text" name="searchString" style="vertical-align:middle" size="21" required="required" /></td>
					<td>
						<button class="ui-button ui-icon-search smoothcorner" />
					</td>
				  </tr>
				</table>
				<table border="0" cellpadding="1" align="center" style="margin:3px 10px;">
				  <tr>
					<td>Search for :&nbsp;</td>
					<td><input type="radio" name="search" value="idea" checked="checked" style="background:transparent;" />&nbsp;Idea&nbsp;</td>
					<td><input type="radio" name="search" value="user" style="background:transparent;" />&nbsp;Username&nbsp;</td>
				  </tr>
				  <?php echo form_close();?>
				</table>
<!-- End of search function -->
			<div id="link">
			<!-- InstanceBeginEditable name="link" -->
			<?php
				if (isset($_SESSION['username']) )
				{
				?>
			<div class="drop" style="display:none;">
			<table border="0" cellspacing="20px" align="left" class="margin padding" style="text-align: right;margin-left:10px;">
			  <tr>
				<td><a href="<?php echo base_url("message/sendMessage")?>" style="text-decoration:none;color:#fff;"><div style="margin:10px;">New Message</div></a></td>
			  </tr>
			  <tr>
				<td><a href="<?php echo base_url("message/")?>" style="text-decoration:none;color:#fff;"><div style="margin:10px;">My Inbox</div></a></td>
			  </tr>
			  <tr>
				<td><a href="<?php echo base_url("browse")?>" style="text-decoration:none;color:#fff;"><div style="margin:10px;">Discover</div></a></td>
			  </tr>
			  <tr>
				<td><a href="<?php echo base_url("feed")?>" style="text-decoration:none;color:#fff;"><div style="margin:10px;">Feed</div></a></td>
			  </tr>
			</table>
			</div>
			<?php }
			?>
			<?php
				if (!isset($_SESSION['username']) )
				{
				?>
			<table border="0" cellspacing="7" align="center" style="font-size:12px; margin-left:-10px;">
	  		<?php
				echo form_open('user/login');

				$username = array(
					'name'	=> 	'username',
					'id'	=>	'username',
					'value'	=> 	set_value('username')
				);

				$password = array(
					'name'	=> 	'password',
					'id'	=>	'password',
					'value'	=> 	''
				);
			  ?>
			  <tr>
				<td style="padding:2px;">Username :</td>
				<td style="padding:2px;"><?php echo form_input($username); ?></td>
			  </tr>
			  <tr>
				<td style="padding:2px;">Password &nbsp;:</td>
				<td style="padding:2px;"><?php echo form_password($password); ?></td>
			  </tr>
			  <tr>
				<td colspan="2" style="padding:2px;"><span><button class="ui-button smoothcorner custom-button-name" type="submit" name="login" style="width:230px;color:#555;" />Sign In</span></td>
			  </tr>
			  <tr>
				<td colspan="2" style="font-size:10px; text-align:center">Don't have an account yet? <a href="<?php echo base_url("user/register")?>" style="color:#00f;">Sign Up</a></td>
			  </tr>
			  <tr>
				<td colspan="2" style="font-size:10px; text-align:center"><a href="<?php echo base_url("user/forgetPassword")?>" style="color:#00f;">Forget Password?</a></td>
			  </tr>
			  <tr><td colspan="2" class="errormsg">
			  	<?php
					if(isset($notification)){
					echo $notification;
					}
				?>
			  </td></tr>
			  <tr><td colspan="2" class="errormsg">
			  <?php
					if(isset($loginerror)){
					echo $loginerror;
					}
			  ?>
			  <?php
					echo form_close();
			  ?>
			  </td></tr>
			</table>
			<?php } ?>
<!-- InstanceEndEditable -->
			</div>
			</div>
			<div id="social">
			<table>
				<tr>
					<td valign="top">
						<div class="g-plusone" data-size="medium" data-annotation="none"></div>
					</td>
					<td valign="top"><a href="https://twitter.com/share" class="twitter-share-button" data-via="ideascover" data-count="none">Tweet</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script><br />
					</td>
					<td valign="top"><div width="0" class="fb-like" layout="button_count" data-send="false" data-width="450" data-show-faces="false"></div>
					</td>
				</tr>
			</table>
			James Cook University<br />
			Jalan Bahagia<br />
			1983478<br />
			+65321874912<br />
			+65189423719
			</div>
			<div id="content">
<!-- End of Body Template -->
<!-- InstanceBeginEditable name="content" -->
		<div align="center" style="font-size:30px;">My Inbox</div>

		<?php if(isset($recipient)):?>
			<div class="ui-widget margin">
			<div class="ui-state-highlight smoothcorner">
			<p>
			<span class="ui-icon ui-icon-circle-check"></span><div style="margin:9px;">Message sent to
		<?php
			echo $recipient;
			?>
			</div>
			</p>
			</div>
		</div>
			<?php endif;?>
			<table class="margin pbsextra" align="center" style="margin:30px auto;">
				<tr>
					<th class="bottomborder padding" style="padding-right: 120px">Sender</th>
					<th class="bottomborder padding" style="padding-right: 120px">Title</th>
					<th class="bottomborder padding" style="padding-right: 180px">Date</th>
					<th class="bottomborder padding" style="padding-right: 40px">Status</th>
					<td class="bottomborder padding" colspan="2"></td>
				</tr>
				<?php if(count($messages) == 0):?>
				<tr>
					<th colspan="5" class="bottomborder padding" style=" text-align: center;">You currently have 0 message in your inbox.<br />Click <a href="<?php echo base_url("message/sendMessage")?>" style="text-decoration:none;">here</a> to start sending messages to other users.</th>
				</tr>
				<?php else:?>
				<?php foreach($messages as $message):?>
				<tr>
					<td class="bottomborder padding"><a style="color: #005FFF" href="<?php echo base_url("user/profile/$message->sender_username "); ?>"><?php echo $message->sender_username?></a></td>
					<td class="bottomborder padding"><?php echo $message->message_title?></td>
					<td class="bottomborder padding"><?php echo $message->message_date?></td>
					<td class="bottomborder padding" >
						<?php if($message->message_isopened == 1){
								echo "Opened";
							} else {
								echo "<b>Unread</b>";
							}?></td>
					<td class="bottomborder padding"><a href="<?php echo base_url("message/view/$message->message_id");?>"><span class="ui-button" style="color:#0081ff;">Open</span></a></td>
					<td class="bottomborder padding"><a><div id="deleteButton" class="deleteMessage" style="color: red;">x</div></a></td>
					<div style="display: none">
						<?php
						$attributes = array(
							'id' => 'deleteform'
						);
							echo form_open('message/delete', $attributes);
							echo form_hidden('message_id', $message->message_id);
							echo form_submit('submit', 'Delete');
							echo form_close();
						?>
				</div>
				</tr>

				<?php endforeach;?>
				<?php endif;?>
			</table>
			<div style="height: 50px;"></div>
	<!-- Footer Template -->
		<!-- InstanceEndEditable -->
		<div id="faqbar">&copy; 2012 Ideascover &nbsp; About Us &nbsp; | &nbsp; FAQ &nbsp; | &nbsp; Terms &nbsp; | &nbsp; Privacy &nbsp; | &nbsp; Jobs &nbsp; | &nbsp; Advertisers &nbsp; | &nbsp; Report &nbsp; | &nbsp; Contact Us</div></div>
		</div>
	</div>
	<!-- -->
	</body>
</html>
